<?php
function displayPage()
{
	if(post('intent') == 'null')
	{
		$blogTitleData = listAllBlogContent(get('name'));
		$titleList = '';
		for($i=0; $i<sizeOf($blogTitleData['contentID']); $i++)
		{
			if ($i % 2 == 0)
			{
				$titleList .= '<span class="link1"><li>'.popOut("javascript:void(0);", 'widget.php?page=content&id='.$blogTitleData['contentID'][$i].'&source='.get('pages').'&pages=blog', $blogTitleData['title'][$i], 'Content Editor', '650', '820').'</li></span>';
			}
			else
			{
				$titleList .= '<span class="link2"><li>'.popOut("javascript:void(0);", 'widget.php?page=content&id='.$blogTitleData['contentID'][$i].'&source='.get('pages').'&pages=blog', $blogTitleData['title'][$i], 'Content Editor', '650', '820').'</li></span>';
			}
			
		}
		
		$stuff ='
		<div id="container">
			<div id="header">
				Edit Contents For: '.get('name').'
			</div>
			<div id="mainStuff">
				<div id="contentContainer">
				<div id="contentTitleStuff">
					Edit Existing Entries:
				</div>
				<div id="contentStuff">
				'.$titleList.'
				</div>
				</div>
				
				<div id="newBlogEntry">
					<div id="contentTitleStuff">
					Add New Entry:
					</div>
					<div id="mceStuff">
					<form method="POST" action="widget.php?page=blog&name='.get('name').'&pages='.get('pages').'" onsubmit="'.jsConfirm('Saving this document cannot be undone. Do you want to continue?').'">
					<input type="hidden" name="intent" value="addNew" />
					Title:<input type="text" id="titleForm" name="title" />
					'.textEditor('contentEditor', 'data', 'nothing', 'Save').'
					
					</div>
				</div>
			</div>
			
			<div id="buttonsPls">
			<div class="buttonsDown">
				<div id="buttonAdd" class="sliderbuttons"><input id="buttonInput" type="button" class="buttons" title="Add New Entry" value="Add Entry" /></div>
			</div>
			
			<div class="buttonsDown">
				<input type="button" class="buttons" title="'.INDEX.get('pages').'" value="Close" onclick="'.jsClose().'" />
			</div>
			</div>
		</div>';
		//page=blog&name=newsblog&pages=edit
		return $stuff;
	}
	else
	{
		$data = createBlogEntry(get('name'), post('title'), post('data'));
		
		$blogTitleData = listAllBlogContent(get('name'));
		$titleList = '';
		for($i=0; $i<sizeOf($blogTitleData['contentID']); $i++)
		{
			if ($i % 2 == 0)
			{
				$titleList .= '<span class="link1"><li>'.popOut("javascript:void(0);", 'widget.php?page=content&id='.$blogTitleData['contentID'][$i].'&source='.get('pages').'&pages=blog', $blogTitleData['title'][$i], 'Content Editor', '650', '820').'</li></span>';
			}
			else
			{
				$titleList .= '<span class="link2"><li>'.popOut("javascript:void(0);", 'widget.php?page=content&id='.$blogTitleData['contentID'][$i].'&source='.get('pages').'&pages=blog', $blogTitleData['title'][$i], 'Content Editor', '650', '820').'</li></span>';
			}
			
		}
		//-----------
		$formStuff ='
		<div id="container">
			<div id="mainStuff">
				<div id="contentContainer">
				<div id="contentTitleStuff">
					Edit Existing Entries:
				</div>
				<div id="contentStuff">
				'.$titleList.'
				</div>
				</div>
				
				<div id="newBlogEntry">
					<div id="contentTitleStuff">
					Add New Entry:
					</div>
					<div id="mceStuff">
					<form method="POST" action="widget.php?page=blog&name='.get('name').'&pages='.get('pages').'" onsubmit="'.jsConfirm('Saving this document cannot be undone. Do you want to continue?').'">
					<input type="hidden" name="intent" value="addNew" />
					Title:<input type="text" id="titleForm" name="title" />
					'.textEditor('contentEditor', 'data', 'nothing', 'Save').'
					
					</div>
				</div>
			</div>
			
			<div id="buttonsPls">
			<div class="buttonsDown">
				<div id="buttonAdd" class="sliderbuttons"><input id="buttonInput" type="button" class="buttons" title="Add New Entry" value="Add Entry" /></div>
			</div>
			
			<div class="buttonsDown">
				<input type="button" class="buttons" title="'.INDEX.get('pages').'" value="Close" onclick="'.jsClose().'" />
			</div>
			</div>
		</div>';
		
		$stuff = '
		<div id="header">
				Edit Contents For: '.get('name').'
			</div>
		<div id="successDiv">
			
			<div id="contentTitleStuff">
				Add New Entry:
			</div>
			<br /><br />A new entry has been added to this element. '.$data.'<br /><br />
			<div style="text-align: center;">
				<span id="buttonClicker"><input type="button" value="Back" class="buttons"/></span>
			</div>
		</div>
		
		<div id="oldFormDiv">
		'.$formStuff.'
		</div>
		';
		return $stuff;
	}

}
?>